//--------------------------------------------------------------------------------------
// Constant Buffer Variables
//--------------------------------------------------------------------------------------
Texture2D		g_Texture;

SamplerState g_Sampler
{
    Filter = MIN_MAG_MIP_LINEAR;
    AddressU = WRAP;
    AddressV = WRAP;
};

BlendState UIBlend
{
    AlphaToCoverageEnable = FALSE;
    BlendEnable[0] = TRUE;
    SrcBlend = SRC_ALPHA;
    DestBlend = INV_SRC_ALPHA;
    BlendOp = ADD;
    SrcBlendAlpha = ONE;
    DestBlendAlpha = ZERO;
    BlendOpAlpha = ADD;
    RenderTargetWriteMask[0] = 0x0F;
};

BlendState NoBlending
{
    BlendEnable[0] = FALSE;
    RenderTargetWriteMask[0] = 0x0F;
};

DepthStencilState DisableDepth
{
    DepthEnable = false;
	StencilEnable = false;
};

DepthStencilState EnableDepth
{
    DepthEnable = true;
	StencilEnable = true;
};

struct VS_OUTPUT
{
    float4 Pos : POSITION;
    float2 Tex : TEXCOORD;
};

VS_OUTPUT VS( float3 vPos : POSITION,
              float2 vTexCoord0 : TEXCOORD )
{
    VS_OUTPUT Output;

    Output.Pos = float4( vPos, 1.0f );
    Output.Tex = vTexCoord0;

    return Output;
}

float4 PS( VS_OUTPUT In ) : SV_Target
{
    return g_Texture.Sample( g_Sampler, In.Tex );
}

float4 PSUntex( VS_OUTPUT In ) : SV_Target
{
    return float4(1.0, 1.0, 1.0, 1.0);
}

technique11 RenderUI
{
    pass P0
    {
        SetVertexShader( CompileShader( vs_5_0, VS() ) );
        SetHullShader(NULL);
        SetDomainShader(NULL);
        SetGeometryShader(NULL);
        SetPixelShader( CompileShader( ps_5_0, PS() ) );
        SetDepthStencilState( DisableDepth, 0 );
        SetBlendState( UIBlend, float4( 0.0f, 0.0f, 0.0f, 0.0f ), 0xFFFFFFFF );
    }
}

technique11 RenderUIUntex
{
    pass P0
    {
        SetVertexShader( CompileShader( vs_5_0, VS() ) );
        SetHullShader(NULL);
        SetDomainShader(NULL);
        SetGeometryShader(NULL);
        SetPixelShader( CompileShader( ps_5_0, PSUntex() ) );
        SetDepthStencilState( DisableDepth, 0 );
        SetBlendState( UIBlend, float4( 0.0f, 0.0f, 0.0f, 0.0f ), 0xFFFFFFFF );
    }
}

technique11 RestoreState
{
    pass P0
    {
        SetDepthStencilState( EnableDepth, 0 );
        SetBlendState( NoBlending, float4( 0.0f, 0.0f, 0.0f, 0.0f ), 0xFFFFFFFF );
    }
}